package com.qj.yantaishan.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qj.yantaishan.domain.Permission;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

@Mapper
public interface PermissionMapper extends BaseMapper<Permission> {
    @Delete("delete from manage_to_permission where mid=#{uid}")
    void deleteManagePermission(Integer uid);

    @Select("select  p.permission_controller from manage_to_permission  mtp left join permission p on mtp.pid =p.id where mtp.mid=#{loginId} ")
    List<String> selectPermissionByUserId(Object loginId);

    @Select("select  p.* from manage_to_permission  mtp left join permission p on mtp.pid =p.id where mtp.mid=#{manageId}")
    List<Map<String, Object>> selectPermissionByManageId(Object manageId);

    @Insert("insert into manage_to_permission(pid,mid) values(#{pid},#{uid})")
    void addManagePermission(@Param("pid") Integer id, @Param("uid") Integer uid);
}
